package com.example.tester.response;

import com.example.tester.enumable.Status;
import lombok.Getter;
import lombok.Setter;

/**
 * @author lzh
 * @date 2019/9/10 - 14:09
 */
@Getter
@Setter
public class SysResponse {

    private int code;
    private String message;
    private Object data;
    private boolean more;

    public SysResponse(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public SysResponse() {
        this.code = Status.SUCCESS.getCode();
        this.message = Status.SUCCESS.getStandardMessage();
    }

    public static SysResponse ofMessage(int code, String message) {
        return new SysResponse(code, message, null);
    }

    public static SysResponse ofSuccess(Object data) {
        return new SysResponse(Status.SUCCESS.getCode(), Status.SUCCESS.getStandardMessage(), data);
    }

    public static SysResponse ofStatus(Status status) {
        return new SysResponse(status.getCode(), status.getStandardMessage(), null);
    }
}
